package com.chezai.client.global;

import android.text.TextUtils;

import com.chezai.client.global.device.C501Hardware;
import com.chezai.client.global.device.C703BHardware;
import com.chezai.client.global.device.DifferenceHardware;
import com.chezai.client.global.device.PhoneHardware;
import com.chezai.client.global.device.QHYC_C103Hardware;

/**
 * 设备工厂类
 * Created by likunyang on 2017/8/24.
 */

public class DeviceFactory {
    public static DifferenceHardware hardware;
    private static DeviceFactory factory;

    static {
        factory = new DeviceFactory();
    }

    private DeviceFactory() {
        if (hardware == null) {
            hardware = createHardware();
        }
    }

    public static DeviceFactory getInstance() {
        return factory;
    }

    private DifferenceHardware createHardware() {
        String channel = TerminalApplication.channelModel;
        if (TextUtils.equals(channel, Const.C703B)) {
            hardware = new C703BHardware();
        } else if (TextUtils.equals(channel, Const.C501)) {
            hardware = new C501Hardware();
        } else if (TextUtils.equals(channel, Const.QHYC_C103)) {
            hardware = new QHYC_C103Hardware();
        } else if (TextUtils.equals(channel, Const._PHONE)) {
            hardware = new PhoneHardware();
        }
        return hardware;
    }

    /**
     * 根据不同的渠道，创建不同的设备实例
     *
     * @return
     */
    public DifferenceHardware getHardware() {
        return hardware;
    }
}
